<template>
  <div class="jd-homepage">
    <!-- Header -->
    <header class="jd-header">
      <div class="header-top">
        <div class="container">
          <div class="location">
            <span>📍 {{ currentLocation }}</span>
          </div>
          <div class="user-menu">
            <a v-if="!isLoggedIn" href="#" @click.prevent="showLogin">你好，请登录</a>
            <a v-else href="#" @click.prevent="showUserInfo">{{ userInfo.username }}</a>
            <a v-if="!isLoggedIn" href="#" @click.prevent="showRegister">免费注册</a>
            <a href="#" @click.prevent="showOrders">我的订单</a>
            <a href="#" @click.prevent="showMyJD">我的京东</a>
            <a href="#" @click.prevent="showMembership">京东会员</a>
            <a href="#" @click.prevent="showEnterprise">企业采购</a>
            <a href="#" @click.prevent="showService">客户服务</a>
            <a href="#" @click.prevent="showInventory">库存管理</a>
          </div>
        </div>
      </div>
      
      <div class="header-main">
        <div class="container">
          <div class="logo">
            <img src="https://via.placeholder.com/200x60/red/white?text=京东" alt="京东" @click="goHome">
          </div>
          <div class="search-box">
            <input 
              type="text" 
              v-model="searchKeyword"
              placeholder="搜索商品"
              @keyup.enter="searchProducts"
              @input="onSearchInput"
            >
            <button class="search-btn" @click="searchProducts">搜索</button>
            <div v-if="searchSuggestions.length > 0" class="search-suggestions">
              <div 
                v-for="suggestion in searchSuggestions" 
                :key="suggestion"
                class="suggestion-item"
                @click="selectSuggestion(suggestion)"
              >
                {{ suggestion }}
              </div>
            </div>
          </div>
          <div class="cart" @click="showCart">
            <span class="cart-icon">🛒</span>
            <span class="cart-text">我的购物车</span>
            <span class="cart-count">{{ cartCount }}</span>
          </div>
        </div>
      </div>
    </header>

    <!-- Navigation -->
    <nav class="jd-nav">
      <div class="container">
        <div class="nav-categories">
          <span 
            v-for="category in navCategories" 
            :key="category.id"
            class="nav-item"
            @click="selectCategory(category)"
          >
            {{ category.name }}
          </span>
        </div>
      </div>
    </nav>

    <!-- Main Content -->
    <main class="jd-main">
      <div class="container">
        <div class="main-content">
          <!-- Left Sidebar -->
          <aside class="sidebar">
            <div class="category-menu">
              <div 
                v-for="category in sidebarCategories" 
                :key="category.id"
                class="category-item"
                @click="selectSidebarCategory(category)"
                @mouseenter="showSubmenu(category)"
                @mouseleave="hideSubmenu(category)"
              >
                <span>{{ category.icon }} {{ category.name }}</span>
                <span class="arrow">></span>
                <div v-if="category.submenu && category.showSubmenu" class="submenu">
                  <div 
                    v-for="subItem in category.submenu" 
                    :key="subItem.id"
                    class="submenu-item"
                    @click.stop="selectSubmenuItem(subItem)"
                  >
                    {{ subItem.name }}
                  </div>
                </div>
              </div>
            </div>
          </aside>

          <!-- Banner Section -->
          <section class="banner-section">
            <div class="main-banner">
              <div class="banner-slider">
                <div 
                  v-for="(banner, index) in banners" 
                  :key="banner.id"
                  class="banner-slide"
                  :class="{ active: currentBannerIndex === index }"
                >
                  <img :src="banner.image" :alt="banner.title">
                  <div class="banner-content">
                    <h3>{{ banner.title }}</h3>
                    <p>{{ banner.description }}</p>
                  </div>
                </div>
                <div class="banner-dots">
                  <span 
                    v-for="(banner, index) in banners" 
                    :key="banner.id"
                    class="dot"
                    :class="{ active: currentBannerIndex === index }"
                    @click="setCurrentBanner(index)"
                  ></span>
                </div>
                <button class="banner-prev" @click="prevBanner">‹</button>
                <button class="banner-next" @click="nextBanner">›</button>
              </div>
            </div>
            <div class="banner-side">
              <div 
                v-for="sideBanner in sideBanners" 
                :key="sideBanner.id"
                class="side-banner"
                @click="handleSideBannerClick(sideBanner)"
              >
                <img :src="sideBanner.image" :alt="sideBanner.title">
              </div>
            </div>
          </section>
        </div>
      </div>
    </main>

    <!-- Featured Products -->
    <section class="featured-products">
      <div class="container">
        <h2 class="section-title">热门商品</h2>
        <div class="product-grid">
          <div 
            v-for="product in featuredProducts" 
            :key="product.id"
            class="product-card"
            @click="viewProduct(product)"
          >
            <div class="product-image">
              <img :src="product.image" :alt="product.title">
              <div class="product-overlay">
                <button class="add-to-cart" @click.stop="addToCart(product)">加入购物车</button>
                <button class="quick-view" @click.stop="quickView(product)">快速查看</button>
              </div>
            </div>
            <div class="product-info">
              <h3 class="product-title">{{ product.title }}</h3>
              <p class="product-desc">{{ product.description }}</p>
              <div class="product-price">
                <span class="current-price">¥{{ product.currentPrice }}</span>
                <span class="original-price">¥{{ product.originalPrice }}</span>
                <span class="discount">{{ product.discount }}折</span>
              </div>
              <div class="product-rating">
                <span class="stars">★★★★☆</span>
                <span class="rating-text">{{ product.rating }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- Footer -->
    <footer class="jd-footer">
      <div class="container">
        <div class="footer-content">
          <div 
            v-for="section in footerSections" 
            :key="section.id"
            class="footer-section"
          >
            <h4>{{ section.title }}</h4>
            <ul>
              <li v-for="link in section.links" :key="link.id">
                <a href="#" @click.prevent="handleFooterLink(link)">{{ link.name }}</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </footer>

    <!-- Login Modal -->
    <div v-if="showLoginModal" class="modal-overlay" @click="closeLoginModal">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>用户登录</h3>
          <button class="close-btn" @click="closeLoginModal">×</button>
        </div>
        <div class="modal-body">
          <p>请先登录您的京东账户</p>
          <button class="login-btn" @click="goToLogin">去登录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted } from 'vue'

// 响应式数据
const currentLocation = ref('北京')
const isLoggedIn = ref(false)
const userInfo = reactive({
  username: 'admin',
  email: 'admin@vitetest.com'
})
const searchKeyword = ref('')
const searchSuggestions = ref<string[]>([])
const cartCount = ref(0)
const currentBannerIndex = ref(0)
const showLoginModal = ref(false)

// 导航分类
const navCategories = ref([
  { id: 1, name: '全部商品分类' },
  { id: 2, name: '服装城' },
  { id: 3, name: '美妆馆' },
  { id: 4, name: '京东超市' },
  { id: 5, name: '生鲜' },
  { id: 6, name: '到家' },
  { id: 7, name: '充值缴费' },
  { id: 8, name: '9.9元拼' },
  { id: 9, name: '领券' },
  { id: 10, name: '领金贴' },
  { id: 11, name: 'plus会员' }
])

// 侧边栏分类
const sidebarCategories = ref([
  {
    id: 1,
    name: '手机数码',
    icon: '📱',
    showSubmenu: false,
    submenu: [
      { id: 1, name: '手机' },
      { id: 2, name: '平板' },
      { id: 3, name: '笔记本' },
      { id: 4, name: '智能穿戴' }
    ]
  },
  {
    id: 2,
    name: '电脑办公',
    icon: '💻',
    showSubmenu: false,
    submenu: [
      { id: 5, name: '台式机' },
      { id: 6, name: '笔记本' },
      { id: 7, name: '显示器' },
      { id: 8, name: '外设' }
    ]
  },
  {
    id: 3,
    name: '家用电器',
    icon: '🏠',
    showSubmenu: false,
    submenu: [
      { id: 9, name: '电视' },
      { id: 10, name: '空调' },
      { id: 11, name: '洗衣机' },
      { id: 12, name: '冰箱' }
    ]
  },
  {
    id: 4,
    name: '服装鞋包',
    icon: '👕',
    showSubmenu: false,
    submenu: [
      { id: 13, name: '男装' },
      { id: 14, name: '女装' },
      { id: 15, name: '内衣' },
      { id: 16, name: '鞋靴' }
    ]
  },
  {
    id: 5,
    name: '美妆护肤',
    icon: '💄',
    showSubmenu: false,
    submenu: [
      { id: 17, name: '面部护理' },
      { id: 18, name: '彩妆' },
      { id: 19, name: '香水' },
      { id: 20, name: '洗护' }
    ]
  },
  {
    id: 6,
    name: '生鲜食品',
    icon: '🍎',
    showSubmenu: false,
    submenu: [
      { id: 21, name: '水果' },
      { id: 22, name: '蔬菜' },
      { id: 23, name: '肉类' },
      { id: 24, name: '海鲜' }
    ]
  },
  {
    id: 7,
    name: '家居建材',
    icon: '🏠',
    showSubmenu: false,
    submenu: [
      { id: 25, name: '家具' },
      { id: 26, name: '家纺' },
      { id: 27, name: '灯具' },
      { id: 28, name: '建材' }
    ]
  },
  {
    id: 8,
    name: '汽车用品',
    icon: '🚗',
    showSubmenu: false,
    submenu: [
      { id: 29, name: '汽车配件' },
      { id: 30, name: '汽车用品' },
      { id: 31, name: '汽车服务' }
    ]
  },
  {
    id: 9,
    name: '运动户外',
    icon: '🎮',
    showSubmenu: false,
    submenu: [
      { id: 32, name: '运动鞋' },
      { id: 33, name: '运动服' },
      { id: 34, name: '健身器材' },
      { id: 35, name: '户外装备' }
    ]
  },
  {
    id: 10,
    name: '图书音像',
    icon: '📚',
    showSubmenu: false,
    submenu: [
      { id: 36, name: '图书' },
      { id: 37, name: '电子书' },
      { id: 38, name: '音像' },
      { id: 39, name: '教育' }
    ]
  }
])

// 轮播图数据
const banners = ref([
  {
    id: 1,
    image: 'https://via.placeholder.com/800x400/ff6b6b/white?text=主轮播图1',
    title: '新品上市',
    description: '限时特惠，抢购从速'
  },
  {
    id: 2,
    image: 'https://via.placeholder.com/800x400/4ecdc4/white?text=主轮播图2',
    title: '品牌专区',
    description: '品质保证，正品直供'
  },
  {
    id: 3,
    image: 'https://via.placeholder.com/800x400/45b7d1/white?text=主轮播图3',
    title: '限时秒杀',
    description: '每日10点，准时开抢'
  }
])

// 侧边广告
const sideBanners = ref([
  {
    id: 1,
    image: 'https://via.placeholder.com/200x200/4ecdc4/white?text=侧边广告1',
    title: '侧边广告1'
  },
  {
    id: 2,
    image: 'https://via.placeholder.com/200x200/45b7d1/white?text=侧边广告2',
    title: '侧边广告2'
  }
])

// 热门商品
const featuredProducts = ref([
  {
    id: 1,
    title: 'Apple iPhone 15 Pro',
    description: '钛金属设计，A17 Pro芯片',
    image: 'https://via.placeholder.com/200x200/ff6b6b/white?text=商品1',
    currentPrice: 7999,
    originalPrice: 8999,
    discount: 8.9,
    rating: 4.8
  },
  {
    id: 2,
    title: '华为 Mate 60 Pro',
    description: '卫星通讯，昆仑玻璃',
    image: 'https://via.placeholder.com/200x200/4ecdc4/white?text=商品2',
    currentPrice: 6999,
    originalPrice: 7999,
    discount: 8.7,
    rating: 4.9
  },
  {
    id: 3,
    title: '小米14 Ultra',
    description: '徕卡光学，骁龙8 Gen 3',
    image: 'https://via.placeholder.com/200x200/45b7d1/white?text=商品3',
    currentPrice: 5999,
    originalPrice: 6499,
    discount: 9.2,
    rating: 4.7
  },
  {
    id: 4,
    title: 'MacBook Pro 14',
    description: 'M3芯片，专业级性能',
    image: 'https://via.placeholder.com/200x200/96ceb4/white?text=商品4',
    currentPrice: 14999,
    originalPrice: 15999,
    discount: 9.4,
    rating: 4.9
  }
])

// 页脚数据
const footerSections = ref([
  {
    id: 1,
    title: '购物指南',
    links: [
      { id: 1, name: '购物流程' },
      { id: 2, name: '会员介绍' },
      { id: 3, name: '常见问题' }
    ]
  },
  {
    id: 2,
    title: '配送方式',
    links: [
      { id: 4, name: '上门自提' },
      { id: 5, name: '211限时达' },
      { id: 6, name: '配送服务查询' }
    ]
  },
  {
    id: 3,
    title: '支付方式',
    links: [
      { id: 7, name: '货到付款' },
      { id: 8, name: '在线支付' },
      { id: 9, name: '分期付款' }
    ]
  },
  {
    id: 4,
    title: '售后服务',
    links: [
      { id: 10, name: '售后政策' },
      { id: 11, name: '价格保护' },
      { id: 12, name: '退款说明' }
    ]
  }
])

// 搜索建议
const searchSuggestionsData = [
  'iPhone 15 Pro',
  '华为 Mate 60',
  '小米14 Ultra',
  'MacBook Pro',
  'iPad Pro',
  'AirPods Pro',
  'Apple Watch',
  '华为手表',
  '小米手环',
  '索尼耳机'
]

// 方法
const showLogin = () => {
  showLoginModal.value = true
}

const closeLoginModal = () => {
  showLoginModal.value = false
}

const goToLogin = () => {
  // 使用页面管理器跳转到登录页面
  const pageManager = (window as any).pageManager
  if (pageManager) {
    pageManager.showLoginPage()
  }
}

// 退出登录
const logout = () => {
  // 清除本地存储的登录信息
  localStorage.removeItem('accessToken')
  localStorage.removeItem('refreshToken')
  localStorage.removeItem('userInfo')
  
  // 更新登录状态
  isLoggedIn.value = false
  
  // 跳转到登录页面
  const pageManager = (window as any).pageManager
  if (pageManager) {
    pageManager.showLoginPage()
  }
}

const showUserInfo = () => {
  const action = confirm(`用户信息：${userInfo.username} (${userInfo.email})\n\n是否要退出登录？`)
  if (action) {
    logout()
  }
}

const showRegister = () => {
  alert('注册功能开发中...')
}

const showOrders = () => {
  if (!isLoggedIn.value) {
    showLogin()
    return
  }
  alert('我的订单')
}

const showMyJD = () => {
  if (!isLoggedIn.value) {
    showLogin()
    return
  }
  alert('我的京东')
}

const showMembership = () => {
  alert('京东会员')
}

const showEnterprise = () => {
  alert('企业采购')
}

const showService = () => {
  alert('客户服务')
}

const showInventory = () => {
  if (!isLoggedIn.value) {
    showLogin()
    return
  }
  // 使用页面管理器跳转到库存管理页面
  const pageManager = (window as any).pageManager
  if (pageManager) {
    pageManager.showInventoryPage()
  }
}

const goHome = () => {
  // 回到首页
  console.log('回到首页')
}

const searchProducts = () => {
  if (searchKeyword.value.trim()) {
    alert(`搜索：${searchKeyword.value}`)
  }
}

const onSearchInput = () => {
  if (searchKeyword.value.trim()) {
    searchSuggestions.value = searchSuggestionsData.filter(item =>
      item.toLowerCase().includes(searchKeyword.value.toLowerCase())
    ).slice(0, 5)
  } else {
    searchSuggestions.value = []
  }
}

const selectSuggestion = (suggestion: string) => {
  searchKeyword.value = suggestion
  searchSuggestions.value = []
  searchProducts()
}

const showCart = () => {
  if (!isLoggedIn.value) {
    showLogin()
    return
  }
  alert(`购物车中有 ${cartCount.value} 件商品`)
}

const selectCategory = (category: any) => {
  alert(`选择分类：${category.name}`)
}

const selectSidebarCategory = (category: any) => {
  alert(`选择侧边栏分类：${category.name}`)
}

const showSubmenu = (category: any) => {
  category.showSubmenu = true
}

const hideSubmenu = (category: any) => {
  category.showSubmenu = false
}

const selectSubmenuItem = (item: any) => {
  if (item.name === '手机') {
    // 打开手机购买页面
    showPhonePurchasePage()
  } else {
    alert(`选择子菜单：${item.name}`)
  }
}

const setCurrentBanner = (index: number) => {
  currentBannerIndex.value = index
}

const prevBanner = () => {
  currentBannerIndex.value = currentBannerIndex.value > 0 
    ? currentBannerIndex.value - 1 
    : banners.value.length - 1
}

const nextBanner = () => {
  currentBannerIndex.value = currentBannerIndex.value < banners.value.length - 1 
    ? currentBannerIndex.value + 1 
    : 0
}

const handleSideBannerClick = (banner: any) => {
  alert(`点击侧边广告：${banner.title}`)
}

const viewProduct = (product: any) => {
  alert(`查看商品：${product.title}`)
}

const addToCart = (product: any) => {
  if (!isLoggedIn.value) {
    showLogin()
    return
  }
  cartCount.value++
  alert(`已将 ${product.title} 加入购物车`)
}

const quickView = (product: any) => {
  alert(`快速查看：${product.title}`)
}

const handleFooterLink = (link: any) => {
  alert(`点击链接：${link.name}`)
}

// 显示手机购买页面
const showPhonePurchasePage = () => {
  // 使用页面管理器显示手机购买页面
  const pageManager = (window as any).pageManager
  if (pageManager) {
    pageManager.showPhonePurchasePage()
  } else {
    // 如果没有页面管理器，直接跳转
    window.location.href = '/phone-purchase'
  }
}

// 自动轮播
let bannerInterval: ReturnType<typeof setInterval> | null = null

onMounted(() => {
  // 检查登录状态
  const token = localStorage.getItem('accessToken')
  if (token) {
    isLoggedIn.value = true
    const userInfoStr = localStorage.getItem('userInfo')
    if (userInfoStr) {
      const storedUserInfo = JSON.parse(userInfoStr)
      userInfo.username = storedUserInfo.username
      userInfo.email = storedUserInfo.email
    }
  }

  // 启动轮播
  bannerInterval = setInterval(() => {
    nextBanner()
  }, 5000)
})

onUnmounted(() => {
  if (bannerInterval) {
    clearInterval(bannerInterval)
  }
})
</script>

<style scoped>
.jd-homepage {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f5f5f5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Header Styles */
.jd-header {
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-top {
  background: #e3e3e3;
  padding: 8px 0;
  font-size: 12px;
}

.header-top .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.location {
  color: #666;
}

.user-menu a {
  color: #666;
  text-decoration: none;
  margin-left: 15px;
  transition: color 0.3s;
}

.user-menu a:hover {
  color: #e1251b;
}

.header-main {
  padding: 20px 0;
}

.header-main .container {
  display: flex;
  align-items: center;
  gap: 30px;
}

.logo img {
  height: 40px;
  cursor: pointer;
  transition: transform 0.3s;
}

.logo img:hover {
  transform: scale(1.05);
}

.search-box {
  flex: 1;
  position: relative;
  max-width: 500px;
  z-index: 9999;
}

.search-box input {
  width: 100%;
  padding: 12px 50px 12px 15px;
  border: 2px solid #e1251b;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  position: relative;
  z-index: 9999;
}

.search-btn {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 50px;
  background: #e1251b;
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: background 0.3s;
}

.search-btn:hover {
  background: #c1191f;
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 9999;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.suggestion-item {
  padding: 10px 15px;
  cursor: pointer;
  transition: background 0.3s;
  border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: #f5f5f5;
  color: #e1251b;
}

.cart {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.cart:hover {
  background: #e1251b;
  color: white;
  border-color: #e1251b;
}

.cart-count {
  background: #e1251b;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

/* Navigation Styles */
.jd-nav {
  background: #e1251b;
  padding: 10px 0;
}

.nav-categories {
  display: flex;
  gap: 30px;
}

.nav-item {
  color: white;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background 0.3s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.2);
}

/* Main Content Styles */
.jd-main {
  padding: 20px 0;
}

.main-content {
  display: flex;
  gap: 20px;
}

/* Sidebar Styles */
.sidebar {
  width: 200px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.category-menu {
  position: relative;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  cursor: pointer;
  transition: background 0.3s;
  position: relative;
}

.category-item:hover {
  background: #f5f5f5;
  color: #e1251b;
}

.arrow {
  color: #999;
  font-size: 12px;
}

.submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  min-width: 150px;
  z-index: 1000;
}

.submenu-item {
  padding: 10px 15px;
  cursor: pointer;
  transition: background 0.3s;
}

.submenu-item:hover {
  background: #f5f5f5;
  color: #e1251b;
}

/* Banner Styles */
.banner-section {
  flex: 1;
  display: flex;
  gap: 20px;
}

.main-banner {
  flex: 1;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.banner-slider {
  position: relative;
  height: 400px;
}

.banner-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s;
}

.banner-slide.active {
  opacity: 1;
}

.banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner-content {
  position: absolute;
  bottom: 20px;
  left: 20px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.banner-content h3 {
  margin: 0 0 10px 0;
  font-size: 24px;
}

.banner-content p {
  margin: 0;
  font-size: 16px;
}

.banner-dots {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: background 0.3s;
}

.dot.active {
  background: white;
}

.banner-prev,
.banner-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  transition: background 0.3s;
}

.banner-prev:hover,
.banner-next:hover {
  background: rgba(0,0,0,0.7);
}

.banner-prev {
  left: 20px;
}

.banner-next {
  right: 20px;
}

.banner-side {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-banner {
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.3s;
}

.side-banner:hover {
  transform: translateY(-2px);
}

.side-banner img {
  width: 100%;
  height: 190px;
  object-fit: cover;
}

/* Featured Products Styles */
.featured-products {
  padding: 40px 0;
  background: white;
}

.section-title {
  text-align: center;
  margin-bottom: 30px;
  font-size: 28px;
  color: #333;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.product-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.product-image {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

.product-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.3s;
}

.product-card:hover .product-overlay {
  opacity: 1;
}

.add-to-cart,
.quick-view {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
}

.add-to-cart {
  background: #e1251b;
  color: white;
}

.add-to-cart:hover {
  background: #c1191f;
}

.quick-view {
  background: white;
  color: #333;
}

.quick-view:hover {
  background: #f5f5f5;
}

.product-info {
  padding: 15px;
}

.product-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: #333;
  line-height: 1.4;
}

.product-desc {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #666;
  line-height: 1.4;
}

.product-price {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.current-price {
  font-size: 18px;
  font-weight: bold;
  color: #e1251b;
}

.original-price {
  font-size: 14px;
  color: #999;
  text-decoration: line-through;
}

.discount {
  font-size: 12px;
  color: #e1251b;
  background: #ffe6e6;
  padding: 2px 6px;
  border-radius: 2px;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stars {
  color: #ffd700;
  font-size: 14px;
}

.rating-text {
  font-size: 12px;
  color: #666;
}

/* Footer Styles */
.jd-footer {
  background: #f8f8f8;
  padding: 40px 0;
  border-top: 1px solid #e5e5e5;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.footer-section h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  color: #333;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section li {
  margin-bottom: 8px;
}

.footer-section a {
  color: #666;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s;
}

.footer-section a:hover {
  color: #e1251b;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal-content {
  background: white;
  border-radius: 8px;
  padding: 0;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  transition: color 0.3s;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
  text-align: center;
}

.modal-body p {
  margin: 0 0 20px 0;
  color: #666;
}

.login-btn {
  background: #e1251b;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.3s;
}

.login-btn:hover {
  background: #c1191f;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-main .container {
    flex-direction: column;
    gap: 15px;
  }
  
  .search-box {
    max-width: 100%;
  }
  
  .nav-categories {
    flex-wrap: wrap;
    gap: 15px;
  }
  
  .main-content {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .banner-section {
    flex-direction: column;
  }
  
  .banner-side {
    width: 100%;
    flex-direction: row;
  }
  
  .side-banner {
    flex: 1;
  }
  
  .product-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .footer-content {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}
</style> 